import request from './request'

type dataType = {
    [key: string]: any
}
type searchType = {
    page:number,
    pagesize:number,
    start?:boolean,
    trash?:boolean,
    keyword:string
}

//获取问卷统计表格

export function getQuestionStatInfo(id:string):Promise<dataType>{
    return request({
        url:`/api/stat/${id}`,
        method:'get',
    })
}


//发布问卷
export function publishQuestion(id:string):Promise<dataType>{
    return request({
        url:`/api/publish/${id}`,
        method:'post',
    })
}


//获取问卷列表(通过路径改变)
export function getQuestionList(params:searchType):Promise<dataType>{
    return request({
        url:'api/question/list',
        method:'get',
        params
    })
}
//保存
export function saveQuestion(data:any):Promise<dataType>{
    return request({
        url:`api/questiondetail`,
        method:'post',
        data
    })
}

//获取问卷详情
export function getQuestion(id:string):Promise<dataType>{
    return request({
        url:`api/questiondetail/${id}`,
        method:'get'
    })
}

//删除问卷
export function deleteQuestion(id:string):Promise<dataType>{
    return request({
        url:`api/question/${id}`,
        method:'delete'
    })
}


//复制问卷
export function CopyQuestion(id:string):Promise<dataType>{
    return request({
        url:`api/question/copy/${id}`,
        method:'get'
    })
}
//修改问卷
export function changeQuestion(id:string):Promise<dataType>{
    return request({
        url:`api/question/${id}`,
        method:'put'
    })
}
//彻底删除

export function deleteQuestions(id:string[]):Promise<dataType>{
    return request({
        url:`api/question`,
        method:'delete'
    })
}




//登录
type loginType = {
    username:string,
    password:string,
    
}

export function UserLogin(params:loginType):Promise<dataType>{
    return request({
        url:'api/user/login',
        method:'post',
        data:params
    })
}


//注册
type registerType = {
    username:string,
    password:string
    nickname?:string
}

export function UserRegister(params:registerType):Promise<dataType>{
    return request({
        url:'api/user/register',
        method:'post',
        data:params
    })
}


//获取用户信息

export function UserInfo():Promise<dataType>{
    return request({
        url:'api/user/info',
        method:'get',
    })
}


